import request from "@/utils/request";
import type { Message, Session } from "./type";

export const getMessageList = (sessionId: string) => {
    return request.get("/message/list", {
        params: {
            'sessionId': sessionId
        }
    });
}

export const sendMessage = (sessionId: string, senderId: string, content: string) => {
    return request.post("/message/send", {
        sessionId,
        senderId,
        content
    })
}

export const createSession = (session: Session) => {
    return request.post("/message/session/create", session)
}

export const getSession = (session: Session) => {
    return request.get("/message/session/get", {
        params: {
            'senderId': session.senderId,
            'receiverId': session.receiverId
        }
    })
}

export const getSessionList = () => {
    return request.get("/message/session/list")
}